package com.yuyou.fn.controller;

import com.yuyou.fn.platform.service.ICaptchaService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * Created by wens on 16-11-14.
 */
@Controller
public class CaptchaController {

    @Resource
    private ICaptchaService captchaService ;

    @RequestMapping("/api/captcha")
    @ResponseBody
    public void verifyCode(HttpServletResponse response, HttpSession session ) throws IOException {
        response.setHeader("Pragma", "No-cache");
        response.setHeader("Cache-Control", "no-cache");
        response.setDateHeader("Expires", 0);
        response.setContentType("image/jpeg");

        captchaService.outputImage(100,40,response.getOutputStream());
        return  ;
    }

}
